<template>
  <div class="category-list">
    <div class="category" v-for="item in categoriesList">
      <div class="category-title">{{item.name}}</div>
      <div class="products">
        <div class="product" v-for="product in item.products" @click="jump2Product(product.id)">
          <img :src="product.firstProductImage.address">
          <div>{{product.name}}</div>
          <div>{{product.promotePrice}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default{
    data() {
      return {

      }
    },
    props: {
      categoriesList: {
        type: Array,
        default: []
      },
    },
    methods: {
      // 跳转至产品页
      jump2Product(id){
        this.$router.push('/product?id='+id)
      }
    },
  }
</script>

<style scoped>
  .category-list{
    width: 1024px;
    background-color: #f5f5f5;
    box-sizing: border-box;
    margin: 10px auto;
    padding: 50px 10px;
  }
  .category{

  }
  .category-title{
    height: 30px;
    line-height: 30px;
  }
  .category-title::before{
    content: '';
    display: inline-block;
    width: 4px;
    height: 30px;
    background-color: #006600;
    float: left;
    margin-right: 10px;
   }
   .products{
     display: flex;
     margin-top: 10px;
     overflow: hidden;
     margin-bottom: 50px;
   }
   .product{
     width: 190px;
     height: 300px;
     cursor: pointer;
     background-color: white;
     border: 1px solid #E2E2E3;
     margin-right: 12px;

   }
   .product:hover{
     border: 1px solid #dd2727;
   }
   .product img{
     width: 190px;
     height: 180px;
   }
   .product>div:nth-child(2){
     width: 150px;
     height: 40px;
     margin: 0 auto;
     margin-top: 20px;
     display: -webkit-box;
     -webkit-box-orient: vertical;
     -webkit-line-clamp: 2;
     overflow: hidden;
     font-size: 12px;
     line-height: 20px;
   }
   .product>div:nth-child(3){
      margin-left: 20px;
      color: #FF003A;
      margin-top: 20px;
   }
</style>
